<div class="layui-form layui-form-pane form-search"  >

    <input  name="type" type="hidden"    value="add"   >
    <input  name="menu_id"   type="hidden"    value="{$menu_id}" >
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('节点')}</label>
        <label class="layui-input-inline">
            <input onblur="this.value=this.value === ''?'#':this.value" name="url" required vali-name="菜单链接" placeholder="请输入菜单链接" value="{$vo.url|default='#'}" class="layui-input">
        </label>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('节点名称')}</label>
        <label class="layui-input-inline">
            <input  name="title"  vali-name="节点名称" placeholder="节点名称" value="{$vo.url|default=''}" class="layui-input">
        </label>
    </div>
    <div class="layui-form-item layui-inline">

        <a class="layui-btn layui-btn-primary" lay-on="add" ><i class="layui-icon"></i> {:lang('添 加')}</a>
    </div>
    <div class="layui-form-item layui-inline">
        <a class="layui-btn layui-btn-primary" data-action="{:url('renewNode')}" data-value="menu_id#{$menu_id}"  data-table-id="IndexPower" ><i class="layui-icon"></i> {:lang('更新')}</a>
    </div>
</div>

<script>
    function abc () {
        console.log(123)
    }

    require(['jquery.autocompleter'], function () {

        var nodes_arr = $.parseJSON('{$nodes_arr|raw|json_encode}')
        $('input[name=url]').autocompleter({
            limit: 6,
            highlightMatches: true,
            template: '{{ label }} <span> {{ title }} </span>',
            callback: function (node) {

                $('input[name=title]').val(nodes_arr[node]);
            },
            source: (function (subjects, data) {
                for (var i in subjects) data.push({value: subjects[i].node, label: subjects[i].node, title: subjects[i].title});
                return data;
            })(JSON.parse('{$nodes|raw|json_encode}'), [])
        })
    });

</script>